from django.contrib import admin
from .models import *
# Register your models here.


class SchoolAdmin(admin.ModelAdmin):
    list_display = ('uname', 'shortname', 'introduce', 'address', 'copyrightmessage', 'version',
                    'starttime', 'endtime', 'longitude', 'latitude', 'role', 'headmastername', 'headmasterphone')
    search_fields = ('uname', 'headmastername')
    list_display_links = ('uname',)


class VideoAdmin(admin.ModelAdmin):
    list_display = ('title', 'site')
    search_fields = ('title',)


class AbilityAdmin(admin.ModelAdmin):
    list_display = ('school', 'powerTitle',  )
    search_fields = ('school__uname', 'powerTitle')
    list_display_links = ('powerTitle',)
    list_filter = ('school__uname',)


class MoonageAdmin(admin.ModelAdmin):
    list_display = ('age', 'abilities', 'shipin')
    search_fields = ('age', )
    list_display_links = ('age',)
    list_filter = ('abilities__powerTitle', )


class TestAdmin(admin.ModelAdmin):
    list_display = ('biaoti', 'value', 'yueling')
    list_display_links = ('biaoti',)
    search_fields = ('biaoti',)
    list_filter = ('yueling','biaoti')


class StudentAdmin(admin.ModelAdmin):
    list_display = ('uname', 'birth', 'gender', 'openschool', 'endschool', 'school')
    list_display_links = ('uname', 'school')
    list_filter = ('school__uname', 'uname')
    search_fields = ('uname',)
    list_editable = ('openschool', 'endschool')


class TestresutlAdmin(admin.ModelAdmin):
    list_display = ('xuesheng', 'yueling', 'score')
    list_filter = ('yueling',)
    search_fields = ('score', 'xuesheng__uname')
    list_display_links = ('xuesheng',)


class TestdetailAdmin(admin.ModelAdmin):
    list_display = ('powername', 'result', 'testresult')
    list_display_links = ('powername',)
    search_fields = ('testresult__xuesheng__uname',)
    list_filter = ('testresult__xuesheng__uname',)


class QuestionresultAdmin(admin.ModelAdmin):
    list_display = ('testdetail', 'questionName', 'getscore')
    list_display_links = ('questionName',)
    search_fields = ('questionName',)
    list_filter = ('testdetail__powername',)


class ChoicequestionsAdmin(admin.ModelAdmin):
    list_display = ('choiceName', 'grade', 'test')
    list_display_links = ('choiceName',)
    list_filter = ('test__biaoti', 'grade')
    search_fields = ('choiceName',)


admin.site.register(School, SchoolAdmin)
admin.site.register(Video, VideoAdmin)
admin.site.register(Ability, AbilityAdmin)
admin.site.register(Moonage, MoonageAdmin)
admin.site.register(Test, TestAdmin)
admin.site.register(Student, StudentAdmin)
admin.site.register(Testresutl, TestresutlAdmin)
admin.site.register(Testdetail, TestdetailAdmin)
admin.site.register(Questionresult, QuestionresultAdmin)
admin.site.register(Choicequestions, ChoicequestionsAdmin)
# admin.site.register(Recordresult)

